﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "教材管理 - 教材基础信息 - 自编或翻印教材");
		
		strAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		pubId = "0000";
		bookId = event.getArg("BID");
		
		rs_bookEntity = queryNew("bid");
		
		currentTab = event.getArg("TabID", "labBooks");
		
		targetArgs = structNew();
		
		/* 读取出版社目录信息 */
		sql = "	SELECT
					b.bid,b.book_name,b.book_edition,b.book_authors,b.book_prise,b.pyid,b.book_isbn
				FROM
					t_book b
				WHERE
					b.pid = :pubId 
				ORDER BY
					b.book_name";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "pubId", value = pubId, cfsqltype = "cf_sql_char");
		rs_book = queryObj.execute(sql = sql).getResult();
		
		/* 生成首字母索引 */
		sql = "	SELECT
					DISTINCT b.pyid
				FROM
					t_book b
				WHERE
					b.pid = :pubId 
				ORDER BY
					b.pyid";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "pubId", value = pubId, cfsqltype = "cf_sql_char");
		rs_bookIndex = queryObj.execute(sql = sql).getResult();
		
		if ( rs_book.recordCount eq 0 ) {
			currentTab = "labBookCreate";
		}
		
		if ( len(bookId) ) {

			/* 读取教材信息 */
			sql = "	SELECT
						b.book_name,b.book_authors,p.publisher,b.book_edition,b.book_prise,b.book_stock,b.book_isbn,b.pyidx,b.bid,b.book_awards
					FROM
						t_book b INNER JOIN t_publisher p ON p.pid = b.pid
					WHERE
						b.bid = :bookId ";
			
			queryObj = new Query(datasource = application.dnsSlave);
			queryObj.addParam(name = "bookId", value = bookId, cfsqltype = "cf_sql_varchar");
			rs_bookEntity = queryObj.execute(sql = sql).getResult();
			
			if (rs_bookEntity.recordCount) {
				currentTab = "labBookInfo";
			}
			
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('bookSchema')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教材征订目录</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>自编讲义及翻印教材
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labBooks">class="active"</cfif> id="labBooks" tabTarget="Books">教材或讲义清单</span>
						<cfif rs_bookEntity.recordCount>
							<span <cfif currentTab eq "labBookInfo">class="active"</cfif> id="labBookInfo" tabTarget="BookInfo">基本讲义信息</span>
							<span <cfif currentTab eq "labBookEdit">class="active"</cfif> id="labBookEdit" tabTarget="BookEdit">修订讲义信息</span>
							<span <cfif currentTab eq "labBookDelete">class="active"</cfif> id="labBookDelete" tabTarget="BookDelete">删除讲义</span>
						</cfif>
						<span <cfif currentTab eq "labBookCreate">class="active"</cfif> id="labBookCreate" tabTarget="BookCreate">录入新项目</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Books" class="tabContent">

					<div class="noticeBlock">
						<cfif rs_book.recordCount>
							<div class="operation">
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('copyDownloadExcel')#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载全部讲义</span></a>
							</div>
						</cfif>
						
						<h3>自编讲义或影印教材</h3>
						<p>
							<span class="img icon16x16 message"></span>
							现有注册讲义或影印教材信息<em><cfoutput>#rs_book.recordCount#</cfoutput></em>条.
							如需要设置新的教材, <a href="javascript:showCreateFrom();">可以通过点击这里进行</a>. 
						</p>
						<hr/>
						
						<div class="UIArrangeOper">
							<cfif rs_bookIndex.recordCount>
								<span>书名索引</span>
                                <cfloop query="rs_bookIndex">
									<a class="opBtn Index letterFilter"><cfoutput>#rs_bookIndex.pyid#</cfoutput></a>
								</cfloop>
								<a class="opBtn Index selected letterReset">ALL</a>
								<script language="javascript" type="text/javascript">
									//<![CDATA[
									<!--
									$(document).ready(function() {
										
										$("a.letterReset").click(function(){
											
											$("a.letterReset").addClass("selected");
											$("a.letterFilter").removeClass("selected");
											
											$("tr[idxletter]", $("#bookList > tbody")).removeClass("hidden_elem");
										});
											
										$("a.letterFilter").click(function(){
											
											$("a.letterReset").removeClass("selected");
											$("a.letterFilter").removeClass("selected");
												
											$(this).addClass("selected");

											var letter = $(this).text();

											$("tr[idxletter!='" + letter + "']", $("#bookList > tbody")).addClass("hidden_elem");
											$("tr[idxletter='" + letter + "']", $("#bookList > tbody")).removeClass("hidden_elem");
												
												
										});
											
									});
									// -->
									//]]>
								</script>
							</cfif>
						</div>
					</div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						function showCreateFrom() {
							$("div.tabLables span").removeClass("active");
							$("div.tabLables span#labBookCreate").addClass("active");
							
							$("div.tabContent[@id!='BookCreate']").hide();
							$("div.tabContent#BookCreate").show();
							return void(0);
						}
						// -->
						//]]>				
					</script>
					
					<cfif rs_book.recordCount>
						
						<table id="bookList" class="UIEditable">
							<thead>
								<tr>
									<td></td>
									<td>书名</td>
									<td>作者</td>
									<td>类别</td>
									<td>条码</td>
									<td>售价</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
								<cfset row = 0 />
                                <cfloop query="rs_book">
									<cfset row++ />
									<cfset structInsert(targetArgs, "BID", rs_book.bid, true) />
									<tr class="editRows" rowid="<cfoutput>#rs_book.bid#</cfoutput>" idxletter="<cfoutput>#rs_book.pyid#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_book.book_name#</cfoutput></td>
										<td><cfoutput>#listFirst(rs_book.book_authors, "/")#</cfoutput><cfif listLen(rs_book.book_authors, "/") gt 1> `等</cfif></td>
										<td nowrap="nowrap"><cfoutput>#dictAdvice.getBookEdition(rs_book.book_edition)#</cfoutput></td>
										<td width="120"><span class="numeric">BK JY-<cfoutput>#rs_book.book_isbn#</cfoutput></span></td>
										<td width="50"><span class="numeric"><cfif rs_book.book_prise gt 0><cfoutput>#numberFormat(rs_book.book_prise, "_.__")#</cfoutput><cfelse>-/-</cfif></span></td>
										<td><a href="<cfoutput>#buildURL('bookOther', targetArgs)#</cfoutput>" class="operation"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</cfif>
					
				</div>
				
				<div id="BookCreate" class="tabContent">

					<!-- createBook -->
					<form id="formCreateBook" onSubmit="javascript:return processVerfiyForm('formCreateBook');" class="formWrapper " method="post" action="<cfoutput>#buildURL('bookOtherCreateDo')#</cfoutput>">
						
						<input name="PubID" type="hidden" value="0000" />
						<input name="ISBN" type="hidden" value="UUID" />
						
						<div class="label">
							<span class="req">*</span><b>书名</b>
							<input name="BookName" id="BookName" type="text" class="typeTextShort" verification="required" maxlength="80" value="<cfoutput>#event.getArg('BookName')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>作者</b>
							<input name="Authors" id="Authors" type="text" class="typeTextShort" verification="required" maxlength="50" value="<cfoutput>#event.getArg('Authors')#</cfoutput>" />
						</div>

						<div class="label">
							<span class="req">*</span><b>材料成本</b>
							<input name="Prise" id="Prise" type="text" class="typeSmallInt" verification="double" maxlength="7" value="<cfoutput>#event.getArg('Prise','0.00')#</cfoutput>" />
						</div>

						<hr/>
						
						<div class="label">
							<b>类型</b>
							<input name="Edition" type="radio" class="typeRadio" value="T1" checked="checked" /> 自编讲义
							<input name="Edition" type="radio" class="typeRadio" value="T2" /> 影印教材
						</div>
						
						<div class="label">
							<b>其他备注信息</b>
							<textarea style="height:60px;" name="Awards"><cfoutput>#event.getArg('Awards')#</cfoutput></textarea>
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
						</div>
					</form>
					<!-- /createBook -->
					
				</div>
				
				<cfif rs_bookEntity.recordCount>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						function showBookModify() {
							
							$("div.tabLables span").removeClass("active");
							$("div.tabLables span#labBookEdit").addClass("active");
							
							$("div.tabContent[@id!='BookEdit']").hide();
							$("div.tabContent#BookEdit").show();
							
						}
						// -->
						//]]>
					</script>
					
					<div id="BookInfo" class="tabContent">
						
						<div class="noticeBlock">
							<h3>《<cfoutput>#rs_bookEntity.book_name#</cfoutput>》</h3>
							<p>
								<span class="img icon16x16 message"></span>
								如需要修改教材信息, <a href="javascript:showBookModify();">可以通过点击这里进行</a>. 
							</p>
							<hr/>
						</div>
						
						<div class="UIDashBoard">
						
							<div class="col2">
								<div class="noticeBlock">
									<p>基本信息</p>
									<ol>
										<li>作者: <cfoutput>#replace( rs_bookEntity.book_authors, "/", ", ", "ALL")#</cfoutput></li>
										<li>出版社 <cfoutput>#rs_bookEntity.publisher#</cfoutput> - <cfoutput>#dictAdvice.getBookEdition( rs_bookEntity.book_edition, ', ')#</cfoutput></li>
										<li>定价 <strong><cfoutput>#numberFormat( rs_bookEntity.book_prise, '____.__')#</cfoutput></strong></li>
										<li>库存 <strong><cfoutput>#rs_bookEntity.book_stock#</cfoutput></strong> 本</li>
									</ol>
								</div>
							</div>
						
							<div class="col2 last">
								<div class="noticeBlock">
										<h3>印刷品条码</h3>
										<p><span class="img icon16x16 message"></span>该条码用于生成征订数据时, 教材的唯一识别码</p>
										<br/>
										<cfset tagISBN = rs_bookEntity.book_isbn />
										<p><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Materials/<cfoutput>#tagISBN#</cfoutput>.png" /></p>
								</div>
							</div>
						
						</div>
						
					</div>
				
					<div id="BookEdit" class="tabContent">
						
						<div class="noticeBlock">
							<h3>《<cfoutput>#rs_bookEntity.book_name#</cfoutput>》 修订</h3>
							<p>
								<span class="img icon16x16 message"></span>
								请注意规范填写教材书名, 作者及ISBN信息
							</p>
							<hr/>
						</div>
						
						<!-- editBook -->
						<form id="formEditBook" onSubmit="javascript:return processVerfiyForm('formEditBook');" class="formWrapper" method="post" action="<cfoutput>#buildURL('bookOtherModifyDo')#</cfoutput>">
						
							<input name="BookID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />
							<input name="BID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />

							<input name="PubID" type="hidden" value="0000" />
							<input name="ISBN" type="hidden" value="UUID" />

							<div class="label">
								<span class="req">*</span><b>书名</b>
								<input name="BookName" id="BookName" type="text" class="typeTextShort" verification="required" maxlength="80" value="<cfoutput>#event.getArg('BookName', rs_bookEntity.book_name)#</cfoutput>" />
							</div>
							
							<div class="label">
								<b>拼音检索信息</b>
								<input name="PinYin" id="PinYin" type="text" class="typePinYinIdx" maxlength="30" value="<cfoutput>#event.getArg('PinYin', rs_bookEntity.pyidx)#</cfoutput>" />
							</div>
							
							<div class="label">
								<span class="req">*</span><b>作者</b>
								<input name="Authors" id="Authors" type="text" class="typeTextShort" verification="required" maxlength="50" value="<cfoutput>#event.getArg('Authors', replace( rs_bookEntity.book_authors, '/', ', ', 'ALL') )#</cfoutput>" />
							</div>
							
							<div class="label">
								<span class="req">*</span><b>材料成本</b>
								<input name="Prise" id="Prise" type="text" class="typeSmallInt" verification="double" maxlength="7" value="<cfoutput>#event.getArg('Prise', numberFormat(rs_bookEntity.book_prise, '_.__'))#</cfoutput>" />
							</div>

							<hr/>

							<div class="label">
								<b>类型</b>
								<input name="Edition" type="radio" class="typeRadio" value="T1" <cfif rs_bookEntity.book_edition eq "T1">checked="checked"</cfif> /> 自编讲义
								<input name="Edition" type="radio" class="typeRadio" value="T2" <cfif rs_bookEntity.book_edition eq "T2">checked="checked"</cfif>/> 影印教材
							</div>
							
							<div class="label">
								<b>其他备注信息</b>
								<textarea name="Awards"><cfoutput>#event.getArg('Awards', rs_bookEntity.book_awards)#</cfoutput></textarea>
							</div>

							<hr/>
						
							<div class="lable">
								<input class="button" type="submit" value="修改" />
								<input onclick="showCreateBookFrom();" class="button1" type="reset" value="返回" />
							</div>
							
						</form>
						
					</div>
				
					<div id="BookDelete" class="tabContent">
						
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>删除教材信息</h3>
							<p>注意: 删除注册教材信息的同时, 会同时删除与教材相关的征订计划,库存, 出入库单等数据信息. </p>
					
							<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('bookOtherRemoveDo')#</cfoutput>">
								<input name="BookID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />
								<div class="lable"><input class="button2" type="submit" value="删除教材" /></div>
							</form>
						</div>
						
					</div>
				
				</cfif>

			</div>
		</li>
	</ul>
</div>